package com.funny.learning.english.model;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

public class UserEntity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// id: "54bd382378a23c1c398b4567",
	// iid: 9,
	// lname: "d@a.com",
	// name: "AKia",
	// mail: "d@a.com",
	// avatar: "",
	// status: "unactivated",
	// uhash: "d4291d3fc41a828bb128067c2e67fe45336761e8",
	// token: "54be721a78a23c2d448b4567"

	private String id;
	private int iid;
	private String lname;
	private String name;
	private String mail;
	private String avatar;
	private String status;
	private String uhash;
	private String token;
	private String sessionId;
	private int coint;

	public UserEntity() {
	}

	public UserEntity(JSONObject jsonObject, JSONObject jObjCoint) {
		uhash = jsonObject.optString("uhash", "");
		id = jsonObject.optString("id", "");
		iid = jsonObject.optInt("iid", 0);
		lname = jsonObject.optString("lname", "");
		name = jsonObject.optString("name", "");
		mail = jsonObject.optString("mail", "");
		avatar = jsonObject.optString("avatar", "");
		status = jsonObject.optString("status", ""); 
		token = jsonObject.optString("token", "");
		
//		coint = jsonObject.optInt("v",0);
	}
	
	

	public int getCoint() {
		return coint;
	}

	public void setCoint(int coint) {
		this.coint = coint;
	}

	public String toJson() {

		try {
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("id", id);
			jsonObject.put("iid", iid);
			jsonObject.put("lname", lname);
			jsonObject.put("name", name);
			jsonObject.put("mail", mail);
			jsonObject.put("avatar", avatar);
			jsonObject.put("status", status);
			jsonObject.put("uhash", uhash);
			jsonObject.put("token", token);
			return jsonObject.toString();
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	public String getId() {
		return id;
	}
	
	

	public String getSessionId() {
		return sessionId;
	}

	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getIid() {
		return iid;
	}

	public void setIid(int iid) {
		this.iid = iid;
	}

	public String getLname() {
		return lname;
	}

	public void setLname(String lname) {
		this.lname = lname;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getUhash() {
		return uhash;
	}

	public void setUhash(String uhash) {
		this.uhash = uhash;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	@Override
	public String toString() {
		return "UserEntity [id=" + id + ", iid=" + iid + ", lname=" + lname
				+ ", name=" + name + ", mail=" + mail + ", avatar=" + avatar
				+ ", status=" + status + ", uhash=" + uhash + ", token="
				+ token + "]";
	}

}
